//
//  UIECGControlTableView.m
//  vhECGTools
//
//  Created by jia yu on 2021/11/23.
//

#import "UIECGControlTableView.h"
#import "UIECGControlTableViewCell.h"
#import "UIECGSettingsView.h"
@interface UIECGControlTableView()<UITableViewDataSource,UITableViewDelegate>{
    
}

@end

@implementation UIECGControlTableView
@synthesize settingsView;
@synthesize lineDictionary;
@synthesize handler;

-(void)setSettingsView:(UIECGSettingsView *)_settingsView{
    settingsView = _settingsView;
}

-(id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    self = [super initWithFrame:frame style:style];
    if (self){
        self.userInteractionEnabled = YES;
        self.dataSource = self;
        self.delegate = self;
    }
    return self;
}

#pragma mark - UITableViewDataSource,UITableViewDelegate
-(NSInteger)numberOfSections{
    return 1;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

-(UIECGControlTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *identifier = @"UIECGControlTableViewCell_Cell_Identifier";
    UIECGControlTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (nil == cell){
        cell = [[UIECGControlTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.backgroundColor = [UIColor whiteColor];
        cell.tableView = self;
        cell.handler = ^(NSString *cellKey, float width, UIColor *color) {
            if (self->handler){
                self->handler(cellKey,width,color);
            }
            return;
        };
    }
    switch (indexPath.row) {
        case 0:
            cell.textLabel.text = @"ECG Line";
            cell.cellKey = ECGLineKey;
            break;
        case 1:
            cell.textLabel.text = @"Bg 1mm lines";
            cell.cellKey = Bg1mmLineKey;
            break;
        case 2:
            cell.textLabel.text = @"Bg 5mm lines";
            cell.cellKey = Bg5mmLineKey;
            break;
        case 3:
            cell.textLabel.text = @"Bg 10mm lines";
            cell.cellKey = Bg10mmLineKey;
            break;
        case 4:
            cell.textLabel.text = @"Bg Color & PixPermm";
            cell.cellKey = BgColorPixPermmKey;
            break;
        default:
            break;
    }
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 30;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    return;
}
@end
